﻿using Avalonia.Controls.Primitives;
using KinonekoSoftware.Drawings;
using KinonekoSoftware.Foundation.IO;

namespace KinonekoSoftware.Platform.Windows
{

    public static class Shell
    {

        public const string ZipExt = "*.zip";
        public const string PngExt = "*.png";

        public static string ZipFilter
        {
            get => LanguageManager.Language switch
            {
                LanguageArea.English  => "Zip File|*.zip",
                LanguageArea.French   => "Fichier Zip|*.zip",
                LanguageArea.Japanese => "Zip ファイル|*.zip",
                LanguageArea.Korean   => "Zip 파일|*.zip",
                LanguageArea.Russian  => "Файл Zip|*.zip",
                _                     => "Zip压缩文件|*.zip",
            };
        }

        public static string PngFilter
        {
            get => LanguageManager.Language switch
            {
                LanguageArea.English  => "PNG File|*.png",
                LanguageArea.French   => "Fichier PNG|*.png",
                LanguageArea.Japanese => "PNG ファイル|*.png",
                LanguageArea.Korean   => "PNG 파일|*.png",
                LanguageArea.Russian  => "Файл PNG|*.png",
                _                     => "图片文件|*.png",
            };
        }

        public static string ImageFilter
        {
            get => LanguageManager.Language switch
            {
                LanguageArea.English  => "Image File|*.png;*.jpg;*.bmp;*.jpeg",
                LanguageArea.French   => "Fichier image|*.png;*.jpg;*.bmp;*.jpeg",
                LanguageArea.Japanese => "画像ファイル|*.png;*.jpg;*.bmp;*.jpeg",
                LanguageArea.Korean   => "Image 파일|*.png;*.jpg;*.bmp;*.jpeg",
                LanguageArea.Russian  => "Файл изображения|*.png;*.jpg;*.bmp;*.jpeg",
                _                     => "图片文件|*.png;*.jpg;*.bmp;*.jpeg",
            };
        }

        public static string MusicFilter
        {
            get => LanguageManager.Language switch
            {
                LanguageArea.English  => "Music File|*.mp3;*.wav",
                LanguageArea.French   => "Fichier de musique|*.mp3;*.wav",
                LanguageArea.Japanese => "音楽ファイル|*.mp3;*.wav",
                LanguageArea.Korean   => "Music 파일|*.mp3;*.wav",
                LanguageArea.Russian  => "Файл с музыкой|*.mp3;*.wav",
                LanguageArea.Germany  => "Die unterlagen|*.mp3;*.wav",
                _                     => "音乐文件|*.mp3;*.wav",
            };
        }
        
        
        
        public static async void CaptureAsync(Control element, int ratio)
        {
            if (element is null)
            {
                return;
            }

            var jxy      = Ioc.Get<ApplicationInformation>().GlobalFolder;
            var snapshot = FolderHelper.CheckDir(Path.Combine(jxy, "Snapshots"));
            var fileName = Path.Combine(snapshot, $"{DateTime.Now:yyyy_M_d_HH_mm_ss}.png");

           
            var ms = Snapshot.CaptureToStream(element, ratio);
            await File.WriteAllBytesAsync(fileName, ms.GetBuffer());
        }
        
    }
}